package com.ruoyi.system.mapper.waterMapper;

import com.ruoyi.system.domain.waterEnity.UserEntity;
import com.ruoyi.system.domain.waterEnity.UserInfoBO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 用户表Mapper
 */
public interface UserMapper {
    //查询全部用户信息
    @Select("select u.id,openId,username,address,name,phone,identify,building from water.user u left join water.building b on u.buildingId = b.id")
    List<UserInfoBO> getAllUser();
    //根据userid查找用户信息
    @Select("select * from water.user where id=#{id}")
    UserEntity selectUserById(int id);
    //设置送货员身份
    @Update("update water.user set identify =#{identify} where id=#{id} ")
    int updateIdentify(UserEntity userEntity);
    @Delete("<script>" +
            "delete from water.user where id in" +
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    int deleteUser(Long[] userids);
    @Select("<script>" +
            "select u.id,openId,username,address,name,phone,identify,building from water.user u left join water.building b on u.buildingId = b.id where u.id in" +
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>"+
            " #{id}" +
            "</foreach>" +
            "</script>")
    List<UserInfoBO> selectStoreByListId(Long[] userids);
    @Select("select u.id,openId,username,address,name,phone,identify,building from water.user u left join water.building b on u.buildingId = b.id where username like concat('%', #{username}, '%')")
    List<UserInfoBO> selectUserByUsername(String username);
    @Select("select u.id,openId,username,address,name,phone,identify,building from water.user u left join water.building b on u.buildingId = b.id where b.id = #{building}")
    List<UserInfoBO> selectUserByBuilding(String building);
    @Select("select u.id,openId,username,address,name,phone,identify,building from water.user u left join water.building b on u.buildingId = b.id where identify = #{identify}")
    List<UserInfoBO> selectUserByIdentify(String identify);
}
